home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS11.ADF
/
Forth
/
Breshenhan
< prev
next >
Wrap
Text File
|
1986-08-05
|
1KB
|
33 lines
\ Bresenham's (or Mitchell's?) circle algorithm.
\ I think it's published in "Fundamentals of Interactive Computer Graphics"
\ by Foley and Van Dam.
\ DOT uses XYSCALE, so the aspect ratio can be changed.
\ I don't think there is much difference in speed between this and
\ Multi-Forth's CIRCLE command, but they draw slightly different circles.
\ I believe this draws a more symmetrical circle than Multi-Forth, and is
\ a good example of the use of locals. It would be a mess without them.
\ There is room for optimization here, but I didn't want to fog things up.
\ Jon R. Bryan 6-8-86
: CIRCLE ( x center\y center\radius -- )
3 OVER 2* - 0
LOCALS| x d y ycenter xcenter |
BEGIN x y <
WHILE
xcenter y - 1+ ycenter x - xcenter y + OVER DOT DOT
xcenter x - ycenter y - xcenter x + 1+ OVER DOT DOT
xcenter y - 1+ ycenter x + 1+ xcenter y + OVER DOT DOT
xcenter x - ycenter y + 1+ xcenter x + 1+ OVER DOT DOT
d 0<
IF x 4* 6+ ADDR.OF d +!
ELSE
x y - 4* 10+ ADDR.OF d +!
-1 ADDR.OF y +!
THEN
1 ADDR.OF x +!
REPEAT
x y =
IF xcenter y - 1+ ycenter x - xcenter y + OVER DOT DOT
xcenter x - ycenter y + 1+ xcenter x + 1+ OVER DOT DOT
THEN ;